﻿// <copyright file="Video.cs" company="DotNetLib">
//
// .netlib: http://www.codeplex.com/DotNetLib
//
// Portions of this were part of the CodePlex "Extensions for .NET Framework"
//    project and written by Marco Minerva, mailto:marco.minerva@gmail.com
//
// This code is released under the New BSD License.
// A copy of this license is available at:
// http://www.codeplex.com/DotNetLib/license
//
// </copyright>

namespace DotNetLib.Compact
{
  using System;
  using System.Runtime.InteropServices;

  /// <summary>
  /// Provides methods for turning the display on and off on a smart client.
  /// </summary>
  public static class Video
  {
    /// <summary>
    /// Turn the display off.
    /// </summary>
    public static void PowerOff()
    {
      IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
      byte[] vpm = new byte[] { 12, 0, 0, 0, 1, 0, 0, 0, (byte)NativeMethods.VideoPowerState.VideoPowerOff, 0, 0, 0, 0 };
      NativeMethods.ExtEscape(hDc, NativeMethods.SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero);
      NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
    }

    /// <summary>
    /// Turn the display on.
    /// </summary>
    public static void PowerOn()
    {
      IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
      byte[] vpm = new byte[] { 12, 0, 0, 0, 1, 0, 0, 0, (byte)NativeMethods.VideoPowerState.VideoPowerOn, 0, 0, 0, 0 };
      NativeMethods.ExtEscape(hDc, NativeMethods.SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero);
      NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
    }
  }
}
